/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author WinKiQue58
 */
@Entity
@Table(name = "SERVICE_PREFERENCE")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "ServicePreference.findAll", query = "SELECT s FROM ServicePreference s"),
    @NamedQuery(name = "ServicePreference.findByIdServicePreference", query = "SELECT s FROM ServicePreference s WHERE s.servicePreferencePK.idServicePreference = :idServicePreference"),
    @NamedQuery(name = "ServicePreference.findByIdRecord", query = "SELECT s FROM ServicePreference s WHERE s.servicePreferencePK.idRecord = :idRecord"),
    @NamedQuery(name = "ServicePreference.findByIdPersonalInfo", query = "SELECT s FROM ServicePreference s WHERE s.servicePreferencePK.idPersonalInfo = :idPersonalInfo"),
    @NamedQuery(name = "ServicePreference.findByIdBranchenterprise", query = "SELECT s FROM ServicePreference s WHERE s.servicePreferencePK.idBranchenterprise = :idBranchenterprise"),
    @NamedQuery(name = "ServicePreference.findByIdEnterprise", query = "SELECT s FROM ServicePreference s WHERE s.servicePreferencePK.idEnterprise = :idEnterprise"),
    @NamedQuery(name = "ServicePreference.findByBuyammount", query = "SELECT s FROM ServicePreference s WHERE s.buyammount = :buyammount"),
    @NamedQuery(name = "ServicePreference.findBySearchammount", query = "SELECT s FROM ServicePreference s WHERE s.searchammount = :searchammount")})
public class ServicePreference implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ServicePreferencePK servicePreferencePK;
    @Basic(optional = false)
    @NotNull
    @Column(name = "BUYAMMOUNT")
    private BigInteger buyammount;
    @Basic(optional = false)
    @NotNull
    @Column(name = "SEARCHAMMOUNT")
    private BigInteger searchammount;
    @JoinColumns({
        @JoinColumn(name = "ID_SERVICE", referencedColumnName = "ID_SERVICE"),
        @JoinColumn(name = "ID_BRANCHENTERPRISE1", referencedColumnName = "ID_BRANCHENTERPRISE"),
        @JoinColumn(name = "ID_ENTERPRISE1", referencedColumnName = "ID_ENTERPRISE")})
    @OneToOne(optional = false, fetch = FetchType.LAZY)
    private Service service;
    @JoinColumns({
        @JoinColumn(name = "ID_RECORD", referencedColumnName = "ID_RECORD", insertable = false, updatable = false),
        @JoinColumn(name = "ID_PERSONAL_INFO", referencedColumnName = "ID_PERSONAL_INFO", insertable = false, updatable = false),
        @JoinColumn(name = "ID_BRANCHENTERPRISE", referencedColumnName = "ID_BRANCHENTERPRISE", insertable = false, updatable = false),
        @JoinColumn(name = "ID_ENTERPRISE", referencedColumnName = "ID_ENTERPRISE", insertable = false, updatable = false)})
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Record record;

    public ServicePreference() {
    }

    public ServicePreference(ServicePreferencePK servicePreferencePK) {
        this.servicePreferencePK = servicePreferencePK;
    }

    public ServicePreference(ServicePreferencePK servicePreferencePK, BigInteger buyammount, BigInteger searchammount) {
        this.servicePreferencePK = servicePreferencePK;
        this.buyammount = buyammount;
        this.searchammount = searchammount;
    }

    public ServicePreference(BigInteger idServicePreference, BigInteger idRecord, BigInteger idPersonalInfo, BigInteger idBranchenterprise, BigInteger idEnterprise) {
        this.servicePreferencePK = new ServicePreferencePK(idServicePreference, idRecord, idPersonalInfo, idBranchenterprise, idEnterprise);
    }

    public ServicePreferencePK getServicePreferencePK() {
        return servicePreferencePK;
    }

    public void setServicePreferencePK(ServicePreferencePK servicePreferencePK) {
        this.servicePreferencePK = servicePreferencePK;
    }

    public BigInteger getBuyammount() {
        return buyammount;
    }

    public void setBuyammount(BigInteger buyammount) {
        this.buyammount = buyammount;
    }

    public BigInteger getSearchammount() {
        return searchammount;
    }

    public void setSearchammount(BigInteger searchammount) {
        this.searchammount = searchammount;
    }

    public Service getService() {
        return service;
    }

    public void setService(Service service) {
        this.service = service;
    }

    public Record getRecord() {
        return record;
    }

    public void setRecord(Record record) {
        this.record = record;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (servicePreferencePK != null ? servicePreferencePK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof ServicePreference)) {
            return false;
        }
        ServicePreference other = (ServicePreference) object;
        if ((this.servicePreferencePK == null && other.servicePreferencePK != null) || (this.servicePreferencePK != null && !this.servicePreferencePK.equals(other.servicePreferencePK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Entity.ServicePreference[ servicePreferencePK=" + servicePreferencePK + " ]";
    }
    
}
